package com.yaorange.jk.service.impl;

import com.yaorange.jk.dao.BaseDao;
import com.yaorange.jk.entity.Finance;
import com.yaorange.jk.entity.Invoice;
import com.yaorange.jk.service.FinanceService;
import com.yaorange.jk.utils.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Transactional
@Service
public class FinanceServiceImpl implements FinanceService {
@Autowired
private BaseDao<Finance,String> financeDao;

@Override
public Pagination findPage(Pagination page) {
return financeDao.pageByHql("from Finance",page.getPageNo(),page.getPageSize(),null);
}

@Override
public List<Finance> findAll() {
    return financeDao.getListByHQL("from Finance");
    }

    @Override
    public void save(Finance model) {
    	model.setState(0d);
    financeDao.save(model);
    }

    @Override
    public void deleteById(String id) {
    financeDao.deleteById(Finance.class,id);
    }

    @Override
    public void update(Finance model) {
    financeDao.update(model);
    }

    @Override
    public Finance findById(String id) {
    return financeDao.get(Finance.class,id);
    }

	@Override
	public void finance(Finance finance) {
		finance.setState(1d);
		financeDao.update(finance);
		
	}

	@Override
	public void cancel(Finance finance) {
		finance.setState(0d);
		financeDao.update(finance);
	}

	
    }
